import { http } from '@/utils'

// export const updateArticle = (data) => {
//   return async () => {
//     await http.post('/mp/articles', data)
//   }
// }
// export const saveArticle = (data) => {
//   return async () => {
//     await http.post('/mp/articles?draft=true', data)
//   }
// }

export const publishOrSaveArticle = (data, isDraft, isEdit) => {
  return async () => {
    if (isEdit) {
      await http.put(`/mp/articles/${data.id}?draft=${isDraft}`, data)
    } else {
      await http.post(`/mp/articles?draft=${isDraft}`, data)
    }
  }
}
export const getArticleById = (id) => {
  return async () => {
    const res = await http.get(`/mp/articles/${id}`)

    return res.data.data
  }
}
